package com.tengju.data.domain.model.wx;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@AllArgsConstructor
public enum WxActivateStatus {
    ENABLED(1, "已激活"),
    DISABLED(2, "已禁用"),
    NOT_ACTIVE(4, "未激活"),
    OUT_WORK(5, "退出企业"),
    SPECIAL(99, "特殊账号"),
    ;

    private Integer code;
    private String desc;

    @JsonCreator
    public static WxActivateStatus form(Integer code) {
        if (code == null) {
            return null;
        }
        for (WxActivateStatus type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }

    @JsonValue
    public Integer getCode() {
        return code;
    }
}
